-
Notifications
You must be signed in to change notification settings - Fork 121
TargetDefinition.java - Code Quality Improvements #2058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
TargetDefinition.java - Code Quality Improvements #2058
Conversation
Optimizations: - Line 629-631: Eliminated unnecessary ArrayList creation and addAll call - changed from 3 lines to 1 line returning new ArrayList<>(Arrays.asList(collection)) - Line 598: Modernized array creation using method reference NameVersionDescriptor[]::new - Line 610: Modernized array creation using method reference TargetBundle[]::new - Line 527: Modernized array creation using method reference TargetBundle[]::new - Line 996: Modernized array creation using method reference TargetFeature[]::new Impact: - Cleaner, more concise code - Slightly better performance by avoiding unnecessary intermediate objects - Modern Java idioms make code easier to maintain - No API changes
|
@vogella if we like this on a broader scope can we please enable the coresponding cleanup actions? Or do you plan anything on this particular class to work on? |
Test Results111 files - 649 111 suites - 649 21m 33s ⏱️ - 37m 50s Results for commit add2013. ± Comparison against base commit dd6dca3. This pull request removes 3321 tests. |
Yes, I plan to look at the timestamp issue. and usually that means I do the save improvements before. Enabling clean-up actions for the project is useful but not related to this change (which was not done via the JDT clean-up action, AFAIK they cannot do such changes). I leave that to later or someone else. |
@jjohnstn can tell better but I'm quite sure I have seen one for "Modernized array creation using method reference" already.
Then you look at the wrong place, this is happening in P2Utils and alike. |
| ArrayList<TargetBundle> result = new ArrayList<>(); | ||
| result.addAll(Arrays.asList(collection)); | ||
| return result; | ||
| return new ArrayList<>(Arrays.asList(collection)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the list should not be modified and you are sure the array doesn't contain null elements, you could also use List.of().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if null can happen or not, so my proposal would be to leave it as it.
Nice, if that exists. I suggest to add this to the nightly batch clean-ups in this case.
IMHO it never harms to look at the general logic while digging. |
|
Wrth build issues: Once I see green builds in PDE again, I will rebase this to see if he have real issues here or not. |
laeubi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, if that exists. I suggest to add this to the nightly batch clean-ups in this case.
Then please do so, we already have a lot of hassle at PDE with the JUnit 6 update I don't want to need review random "optimizations" done by another tool now without any added benefits.
Optimizations:
Impact: